import { request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(obj: ResultType) {
  if (obj.result?.resultCode === '000000') {
    return obj.data
  }

  throw new Error('错误')
}

/** 查询字典项列表 */
export const queryZdxList = (params?: any) =>
  request.get('/zdx/queryZdxInfo', { params }).then((res: any) => adapter(res))

/** 查询字典项 */
export const queryZdInfo = (params?: any) =>
  request.get('/zd/queryZdInfo', { params }).then((res: any) => adapter(res))

//查询项目名称字典
export const queryXmmcInfoList = (params?: any) =>
  request.get('/zd/queryXmmcInfoList', { params }).then((res: any) => adapter(res))

//查询企业树形数据
export const queryQylb = (params?: any) =>
  request.get('/jcdw/queryJcdwInfoMap', { params }).then((res: any) => adapter(res))

//查询企业名称字典
export const queryQymcInfoList = (params?: any) =>
  request.get('/zd/queryQymcInfoList', { params }).then((res: any) => adapter(res))

//查询管理单位列表
export const queryGldwInfoList = (params?: any) =>
  request.get('/gldw/queryGldwInfoList', { params }).then((res: any) => adapter(res))
